#ifndef __APP_H__
#define __APP_H__

#include "Config.h"
#include "PCF8563.h"

#define FONT_H 16

#define TASK_MENUS 1
#define TASK_KEYS 2
#define TASK_ALARM 3
#define TASK_COUNTDOWN 4
#define TASK_DHT 5
#define TASK_PEDOMETER 6
#define TASK_BLUETOOTH 7
#define TASK_GAME 8
#define TASK_MOTOR 9
#define TASK_BUZZER 10
#define TASK_SET_TIME 11
#define TASK_BGM 12
#define TASK_MUSIC 13
#define TASK_MUSIC_MENU 14

#define MENU_LEN 9

#define CLIP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
#define LIMIT_VALUE_CHANGE(x, min, max, n) \
  if (x >= max && n > 0) {                          \
    x = min;                               \
  } else if (x <= min && n < 0) {                   \
    x = max;                               \
  } else {                                 \
    x += n;                                \
  }

extern u8 menu_no;
extern u8 menu_level;
extern u8 alarm_enable;
extern int8 alarm_menu_no;
extern char move;
extern u8 is_game;
extern u32 step_cnt;
extern Alarm_t a;
extern Alarm_t a_temp;
extern u8 alarm_enable_changed;
extern u8 timer_enable;
extern u8 time_menu_no;
extern Clock_t t;
extern u8 timer_count;
extern u8 timer_set;
extern u8 music_menu_no;
extern u8 is_music_play;
// extern Clock_t t_temp;

extern void change_menu(int value);
extern u8 centerd_pos_str(u8 n);

typedef enum {
  MENU_MAIN,
  MENU_SET_TIME,
  MENU_ALARM,
  MENU_COUNTDOWN,
  MENU_DHT,
  MENU_MUSIC,
  MENU_GAME,
  MENU_PEDOMETER,
  MENU_BLUETOOTH,
} Menu_item;

#endif